<template>
	<view @tap="handelClick" class="score-commodity__-content">
		<view class="image-content">
			<image :src="src" mode="aspectFill"></image>
		</view>
		<view class="body">
			<view class="describe">
				{{describe}}
			</view>
			<view class="score-change">
				<view class="score">
					<view class="iconfont">图</view>
					<view class="number">{{score}}积分</view>
				</view>
				<view class="change">已兑换{{change}}件</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			// 商品Id，外部点击后返回该id
			id: {
				type: [String, Number],
				default: ''
			},
			// 商品图片链接
			src: {
				type: String,
				default: ''
			},
			// 商品描述
			describe: {
				type: String,
				default: 0
			},
			// 商品积分
			score: {
				type: [String, Number],
				default: 0
			},
			// 已兑换数量
			change: {
				type: [String, Number],
				default: 0
			}

		},
		data() {
			return {

			}
		},
		methods: {
			handelClick(e) {
				e.target.commodity_id = this.id
				this.$emit('event', this.id)
			}
		}
	}
</script>

<style lang="scss" scoped>
	// 积分商品展示
	.score-commodity__-content {
		width: 100%;
		overflow: hidden;
		box-shadow: 0px 0px 12upx rgba(0, 0, 0, 0.1);
		margin-top: 20upx;
		.image-content {
			width: 100%;
			height: 350upx;
			background-color: #CFE8F1;
			border-radius: 10upx 10upx 0upx 0upx;

			image {
				border-radius: 10upx 10upx 0upx 0upx;
				width: 100%;
				height: 100%;
			}
		}

		.body {
			padding: 20upx;

			.describe {
				width: 100%;
				overflow: hidden; //将超出的部分隐藏
				text-overflow: ellipsis; //超出部分用省略号显示
				display: -webkit-box;
				-webkit-box-orient: vertical;
				-webkit-line-clamp: 2;
				font-size: 26upx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				line-height: 38upx;
				color: #333333;
				opacity: 1;
			}

			.score-change {
				margin-top: 10upx;
				padding-bottom: 20upx;
				display: flex;

				.score {
					display: flex;

					.iconfont {
						width: 36upx;
						height: 36upx;
						line-height: 36upx;
						text-align: center;
						color: #FFFFFF;
						border-radius: 36upx;
						background-color: #EC9503;
						font-size: 24upx;
					}

					.number {
						margin-left: 10upx;
						font-size: 28upx;
						font-family: Source Han Sans CN;
						font-weight: bold;
						line-height: 40upx;
						color: #E48D04;
						opacity: 1;
					}
				}

				.change {
					margin-left: auto;
					font-size: 20upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					line-height: 30upx;
					color: #999999;
					opacity: 1;
				}
			}
		}
	}
</style>
